<template>
  <div class="policy-content">
    <div class="policy-position">
      <div class="block"></div>
      <div class="title" style="font-family: 'fzhzgbjianti';">
        政策补贴
      </div>
    </div>
    <div class="details-content">
      <div class="left-details">
        <router-link :to=" {path:'/Policy/Details1',query:{id:tableId}}" class="select-item" v-for="(item,index) in policyList" :key="item.type">
          <div class="policy-select" :class="tableId===item.type?'router-link-active':''" @click="tableId=item.type">
            {{ item.typeText }}
            <!--            <div class="policy-select">（{{item.count }}）</div>-->
          </div>
          <img src="../../assets/Policy/right.png" alt="" v-if="tableId===item.type">
        </router-link>
      </div>
      <div class="right-details"  v-loading="detailListLoading">
        <template v-if="detailList.length>0">
          <div class="details-item" v-for="(item,index) in detailList" :key="item.id">
            <div class="title">
              <div class="title-content">{{ item.title }}</div>
              <div class="enter" @click="skip(item.id)">
                <!--                <div class="enter" @click="skip(item.id)">-->
                点击查看
              </div>
            </div>
<!--            <div class="data">-->
<!--              {{ item.data }}-->
<!--            </div>-->
          </div>
        </template>
        <el-empty v-else style="display: flex;justify-content: center;align-items: center;"></el-empty>
        <div v-if="detailList.length>0 && count>limit"  class="paging">
          <el-pagination
              background
              :page-size="limit"
              layout="prev, pager, next"
              :total="count"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange" >
          </el-pagination>
        </div>
      </div>

    </div>
    <Modal v-if="modalShow" width="950px" height="1100px" @closeModal="modalShow=false" :title="modalTitle">
      <div class="details-content1" v-loading="detailLoading">
        <div class="title">{{info.title}}</div>
        <div class="small-title">
          <div class="data">发布时间：{{info.crt_time}}</div>
          <div class="genre" style="display: flex"> 政策类型：{{ info.abstract }}
            <div v-if="info.abstract==''">暂未分类</div>
          </div>
        </div>
        <div class="striping"></div>
        <div class="bottom">
          <div class="text" v-html="info.content" v-if="info.content"></div>
        </div>
      </div>
    </Modal>
  </div>
</template>

<script>
import {getNewsCountApi, getNewsDetailApi, getNewsListApi} from "@/api/policy";
import Modal from "@/components/Modal/Modal.vue";

export default {
  name: "Policy",
  data(){
    return{
      detailListLoading:false,
      modalTitle:'文章详情',
      detailLoading:false,
      info:{
        title:'',
        crt_time:'',
        content:''
      },
      id:1,
      tableId: 2105,
      modalShow:false,
      policyList:[
      //     {
      //   type:2103,
      //   typeText:'通知公告'
      // },{
      //   type:2104,
      //   typeText:'工作动态'
      // },
        {
        type:2143,
        typeText:'就业类'
      },{
        type:2145,
        typeText:'创业类'
      },{
        type:2146,
        typeText:'社保类'
      },{
        type:2147,
        typeText:'培训类'
      },{
        type:2109,
        typeText:'其他类'
      }],
      detailList:[],
      page:1,
      limit:7,
      count:0
    }
  },
  watch:{//监听
    tableId:{
      handler(value){
        this.tableId = value
        this.getList()
      }
    }
  },
  methods:{
    skip(id){
      // this.$router.push({ name: 'Details',query:{id:id} })
      this.id = id
      this.getDetail()
      this.modalShow = true
    },
    getDetail() {
      this.detailLoading = true
      getNewsDetailApi({id:this.id}).then((res) => {
        this.info = res[0];
      }).finally(()=>{
        this.detailLoading = false
      })
    },
    getList() {
      this.detailListLoading = true
      getNewsListApi({page:this.page,limit:this.limit,type:this.tableId}).then((res) => {
        this.detailList = res.list;
        this.count=res.count
      }).finally(()=>{
        this.detailListLoading = false
      })
    },
    getCount() {
      getNewsCountApi({}).then((res) => {
        this.policyList = res
      }).catch((res) => {
        // console.log(res)
      })
    },
    handleSizeChange(e) {
      this.limit = e
      this.getList()
    },
    // 当前页change
    handleCurrentChange(e) {
      this.page = e
      this.getList()
    },
  },
  components:{
    Modal
  },
  mounted() {
    this.getList()
    //this.getCount()
  }
}
</script>


<style lang="scss" scoped>
.details-content1{
  width: 100%;
  height: 615px;
  background-color: #fff;
  box-sizing: border-box;
  border-radius: 20px;
  margin-top: 30px;
  padding: 45px 45px;
  .title{
    font-size: 34px;
    font-weight: bold;
    width: 100%;
    text-align: center;
    margin-bottom: 30px;
  }
  .striping{
    margin-top: 20px;
    width: 100%;
    height: 2px;
    background-color: #D8D8D8;
  }
  .bottom{
    height: 400px;
    box-sizing: border-box;
    padding: 35px 0;
    display: flex;
    .text {
      font-size: 20px;
      text-indent: 2em;
      line-height: 60px;
      color: #434343;
    }
  }
  .small-title {
    display: flex;
    font-size: 20px;
    line-height: 60px;
    color: #A7A7A7;
    .data{
      width: 50%;
      text-align: right;
      padding-right: 20px;
    }
    .genre{
      width: 50%;
      text-align: left;
      padding-left: 20px;
    }
  }

}
.policy-content{
  a{
    text-decoration: none;
    color: #000;
  }
  .policy-position{
    width: 800px;
    height: 70px;
    background-color: #fff;
    color: #498CF3;
    padding: 0 30px;
    border-radius: 20px;
    margin: 30px auto;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    //padding: 0 1;
    .block{
      background-color: #498CF3;
      width: 10px;
      height: 37px;
      border-radius: 15px;
      margin-right: 15px;
    }
    .title{
      font-size: 25px;
      padding-top: 3px;
    }
  }
  .details-content{
    box-sizing: border-box;
    width: 800px;
    margin: 20px auto;
    .left-details{
      display: flex;
      flex-wrap: wrap;
      box-sizing: border-box;
      width: 800px;
      background-color: #fff;
      border-radius: 20px;
      padding: 30px;
      margin-bottom: 20px;
      .select-item{
        width: 180px;
        height: 50px;
        display: flex;
        justify-content: center;
        align-items: center;
        box-sizing: border-box;

        .policy-select{
          font-size: 21px;
          display: flex;
        }
        .router-link-active{
          color: #498CF3;
        }
        img{
          width: 25px;
          height: 25px;
        }
      }

    }
    .right-details{
      box-sizing: border-box;
      width: 800px;
      .details-item{
        width: 100%;
        height: 150px;
        box-sizing: border-box;
        background-color: #fff;
        border-radius: 20px;
        margin-bottom: 10px;
        padding: 30px;
        .title-content{
          width: 80%;
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 2;
        }
        .enter{
          width: 100px;
          height: 39px;
          background-color: #FFFFFF;
          border: 1px solid #5593F3;
          color: #5593F3;
          border-radius: 20px;
          text-align: center;
          line-height: 36px;
          font-size: 15px;
          position: absolute;
          right: 0;
          bottom: -5px;
        }
        .title{
          position: relative;
          height: 100%;
          font-size: 25px;
          line-height: 50px;
          .symbol{
            width: 5px;
            height: 5px;
            border-radius: 10px;
            background-color: #5593F3;
            margin: 0 36px;
          }
        }
        .data{
          display: flex;
          align-items: center;
          justify-content: space-between;
          color: #797979;
          font-size: 25px;


        }
      }
      .paging{
        display: flex;
        justify-content: center;
        margin: 30px auto;
        .el-pagination is-background{
          display: flex;
          text-decoration: none;
        }
      }
    }
  }
}

</style>
